<?php

namespace App\Http\Controllers\Front;

use App\Http\Requests;
use App\Http\Requests\Front\collection\CollectionStoreRequest;
use App\Http\Controllers\Controller;
use App\Repositories\CollectionRepository;

class MyCollectionController extends Controller
{

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param CollectionRepository $collectionRepository
     * @param CollectionStoreRequest $collectionStoreRequest
     * @return int id 收藏id;
     */
    public function store(CollectionRepository $collectionRepository, CollectionStoreRequest $collectionStoreRequest)
    {
        return $collectionRepository->save($collectionStoreRequest->all());
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * 取消收藏
     * @param CollectionRepository $collectionRepository
     * @param $id
     */
    public function destroy(CollectionRepository $collectionRepository, $id)
    {
        $collectionRepository->del($id);
    }

    /**
     * 查询分类收藏数量
     * @param CollectionRepository $collectionRepository
     * @param $type 分类类型(Enum{SHOP, BRAND, GOODS})
     * @return int num 数量
     */
    public function getNumOfCollectionByType(CollectionRepository $collectionRepository, $type){
        return $collectionRepository->getNumOfUserCollectionByType("4", "SHOP");
//        $user = Auth::user();
//        return $collectionRepository->getNumOfUserCollectionByType($user->id, $type);
    }

    /**
     * 获取分类收藏内容分页返回
     * @param CollectionRepository $collectionRepository
     * @param $type
     * @param $page
     * @return \App\Interfaces\UserCollection
     */
    public function getCollectionByType(CollectionRepository $collectionRepository, $type, $page){
        return $collectionRepository->getUserCollectionByType("4", "SHOP", 1);
//        $user = Auth::user();
//        return $collectionRepository->getUserCollectionByType($user->id, $type, $page);
    }
}
